﻿using HCQ2_Model.APPModel.ParamModel;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HCQ2_Model
{
    /// <summary>
    ///  体验记录模型
    /// </summary>
    public class ExperienceRecord: BaseAPI
    {
        /// <summary>
        ///  完成状态
        /// </summary>
        public bool status { get; set; }
        /// <summary>
        ///  退出时间点
        /// </summary>
        public string out_time { get; set; }
        public int er_id { get; set; }
        public int user_id { get; set; }
        public string user_name { get; set; }
        public int file_id { get; set; }
        public string file_name { get; set; }
        public string folder_name { get; set; }
        [Required(ErrorMessage = "in_date：进入时间必填项")]
        public string in_date { get; set; }
        public string out_date { get; set; }
        public string em_time { get; set; } = "0";
        public decimal? x_place { get; set; }
        public decimal? y_place { get; set; }
        public decimal? z_place { get; set; }
        public decimal? score { get; set; }
        public string video_url { get; set; }
        /// <summary>
        ///  关卡代码
        /// </summary>
        //[Required(ErrorMessage = "folder_code：关卡代码必填项")]
        public string folder_code { get; set; }
        /// <summary>
        /// 课件代码
        /// </summary>
        //[Required(ErrorMessage = "file_code：作品代码必填项")]
        public string file_code { get; set; }

        public T_VRExperienceRecord ToEntity()
        {
            return new T_VRExperienceRecord
            {
                out_time = this.out_time,
                user_id = this.user_id,
                user_name = this.user_name,
                file_id = this.file_id,
                file_name = this.file_name,
                folder_name = this.folder_name,
                in_date = DateTime.ParseExact(this.in_date, "yyyyMMddHHmmss", CultureInfo.CurrentCulture, DateTimeStyles.None),
                out_date = (!string.IsNullOrEmpty(this.out_date)) ? DateTime.ParseExact(this.out_date, "yyyyMMddHHmmss", CultureInfo.CurrentCulture, DateTimeStyles.None) : (DateTime?)null,
                em_time = this.em_time,
                x_place = this.x_place,
                y_place = this.y_place,
                z_place = this.z_place,
                score = this.score,
                video_url = this.video_url,
                folder_code = this.folder_code,
                file_code = this.file_code
            };
        }
    }
    public partial class T_VRExperienceRecord
    {
        public ExperienceRecord ToPOCO()
        {
            return new ExperienceRecord
            {
                er_id = this.er_id,
                user_id = this.user_id,
                user_name = this.user_name,
                file_id = this.file_id,
                file_name = this.file_name,
                folder_name = this.folder_name,
                in_date = this.in_date.ToString("yyyy-MM-dd HH:mm"),
                out_date = (this.out_date != null) ? this.out_date?.ToString("yyyy-MM-dd HH:mm") : "",
                em_time = this.em_time,
                x_place = this.x_place,
                y_place = this.y_place,
                z_place = this.z_place,
                score = this.score,
                video_url = this.video_url,
                folder_code = this.folder_code,
                file_code = this.file_code
            };
        }
    }
}
